#ifndef BASICIO_H
#define BASICIO_H

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"

#define MAX668_SD   21
#define HV_CLK      13
#define HV_DIN      4
#define HV_LE       15
#define Fila_EN     19
#define Anode_EN    10
#define D1_F        23
#define D2_F        18
#define OUTPP_PIN   (1ULL << MAX668_SD) | (1ULL << HV_CLK) | (1ULL << HV_DIN) | (1ULL << HV_LE) | (1ULL << Fila_EN) | (1ULL << Anode_EN) | (1ULL << D1_F) | (1ULL << D2_F)

#define BMA_SCLK    25
#define BMA_SDA     26
#define OUTOD_PIN   (1ULL << BMA_SCLK) | (1ULL << BMA_SDA)

#define BMA_INT1    34
#define BMA_INT2    35
#define VBAT_ADC    14
#define CHRG_STAT   22
#define INFLOATING_PIN  (1ULL << BMA_INT1) | (1ULL << BMA_INT2) | (1ULL << VBAT_ADC) | (1ULL << CHRG_STAT)



#define HV_CLK_H    gpio_set_level(HV_CLK, 1)
#define HV_CLK_L    gpio_set_level(HV_CLK, 0)
#define HV_DIN_H    gpio_set_level(HV_DIN, 1)
#define HV_DIN_L    gpio_set_level(HV_DIN, 0)
#define HV_LE_H     gpio_set_level(HV_LE, 1)
#define HV_LE_L     gpio_set_level(HV_LE, 0)

#define BMA_SCLK_H  gpio_set_level(BMA_SCLK, 1)
#define BMA_SCLK_L  gpio_set_level(BMA_SCLK, 0)
#define BMA_SDA_H   gpio_set_level(BMA_SDA, 1)
#define BMA_SDA_L   gpio_set_level(BMA_SDA, 0)

#define HV_EN       gpio_set_level(MAX668_SD, 1)
#define HV_SD       gpio_set_level(MAX668_SD, 0)

#define VDD1V2_EN    gpio_set_level(Fila_EN, 1)
#define VDD1V2_SD    gpio_set_level(Fila_EN, 0)
#define VDD28_EN    gpio_set_level(Anode_EN, 1)
#define VDD28_SD    gpio_set_level(Anode_EN, 0)

#define D1_EN       gpio_set_level(D1_F, 1)
#define D1_SD       gpio_set_level(D1_F, 0)
#define D2_EN       gpio_set_level(D2_F, 1)
#define D2_SD       gpio_set_level(D2_F, 0)

#define ReadVB      gpio_get_level(VBAT_ADC)


void basicio_init(void);
static void OUTPP_PIN_init(void);
static void OUTOD_PIN_init(void);
static void INFLOATING_PIN_init(void);


#endif




